﻿using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class WarehouseListModel : ModelBase
    {
        public WarehouseListModel()
        {
            client.DeleteWarehouseCompleted += DoDeleteWarehouseCompleted;
            client.GetWarehouseCollectionCompleted += DoGetWarehouseCollectionCompleted;
            client.GetSingleWarehouseCompleted += DoGetSingleWarehouseCompleted;
            client.UndoDeleteWarehouseCompleted += DoUndoDeleteWarehouseCompleted;
        }

        #region UndoDeleteWarehouse

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteWarehouseCompleted;

        public int UndoDeleteWarehouseAsync(int objId)
        {
            client.UndoDeleteWarehouseAsync(objId);
            return WebConstants.MagicNumer;
        }

        void DoUndoDeleteWarehouseCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (UndoDeleteWarehouseCompleted != null)
            {
                UndoDeleteWarehouseCompleted(sender, e);
            }
        }

        #endregion

        #region GetWarehouseCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Warehouse>> GetWarehouseCollectionCompleted;

        public int GetWarehouseCollectionAsync(bool isShowAll)
        {
            client.GetWarehouseCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        void DoGetWarehouseCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Warehouse> e)
        {
            if (GetWarehouseCollectionCompleted != null)
            {
                GetWarehouseCollectionCompleted(sender, e);
            }
        }

        #endregion

        #region DeleteWarehouse

        public event EventHandler<FeedbackCompletedEventArgs> DeleteWarehouseCompleted;

        public int DeleteWarehouseAsync(int data)
        {
            client.DeleteWarehouseAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoDeleteWarehouseCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (DeleteWarehouseCompleted != null)
            {
                DeleteWarehouseCompleted(sender, e);
            }
        }

        #endregion

        #region GetSingleWarehouse

        public event EventHandler<SingleFeedbackCompletedEventArgs<Warehouse>> GetSingleWarehouseCompleted;

        public int GetSingleWarehouseAsync(int WarehouseID)
        {
            client.GetSingleWarehouseAsync(WarehouseID);
            return WebConstants.MagicNumer;
        }

        void DoGetSingleWarehouseCompleted(object sender, SingleFeedbackCompletedEventArgs<Warehouse> e)
        {
            if (GetSingleWarehouseCompleted != null)
            {
                GetSingleWarehouseCompleted(sender, e);
            }
        }

        #endregion
    }
}
